home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / cenvid.zip / TEE.CMM < prev    next >
Text File  |  1993-03-26  |  863b  |  32 lines

  1. // Tee.cmm  Send lines to screen and to output file
  2.  
  3.  
  4. main(argc,argv)
  5. {
  6.    if ( 2 != argc )
  7.       Instructions();
  8.    else {
  9.       // open ouput file
  10.       if ( NULL == (fp=fopen(argv[1],"w")) )
  11.          printf("Could not open file \"%s\" for writing.\a\n",argv[1])
  12.       else {
  13.          // read in each line, and send to file and screen
  14.          while ( NULL != (line=gets()) ) {
  15.             printf("%s\n",line)
  16.             fprintf(fp,"%s\n",line)
  17.          }
  18.          fclose(fp)
  19.       }
  20.    }
  21. }
  22.  
  23.  
  24. Instructions()
  25. {
  26.    printf("Tee.cmm - Pipe output to screen AND to a file\n");
  27.    printf("USAGE: Tee.cmm <FileSpec>\n");
  28.    printf("  Where:  FileSpec = Name of file to create and write text to\n");
  29.    printf("Example: To see output of a dir listing, but also save it in a file:\n");
  30.    printf("     dir | cenvi tee.cmm dir.txt\n");
  31. }
  32.